<?php
namespace app\api\controller;


use think\Db;

/**
 * @title 赛事分类
 * @description 接口说明
 * @group 微信报名分销
 * @header name:authorization require:1 default: desc:登陆的token
 */
class MatchCate extends Base
{
    protected $_order = 'id asc';

    /**
     * @title 获取
     * @description 接口说明
     * @author hardy
     * @url /api/MatchCate
     * @method GET
     *
     * @param name:match_id type:int require:1 default:0 other: desc:赛事id
     *
     * @return name:分类名称
     * @return sort:排序，值越小越靠前
     *
     * @return list:消息列表,有page参数则返回值list，list是一个数组，
     */
    public function gets()
    {
        $data = input('match_id');
        if (empty($data)){
            $this->responseFail('赛事id必填');
        }
        $data = model('Match')->where('id', $data)->value('cate_id');
        if (empty($data)){
            $this->responseSuccess([]);
        }
        $data = explode(',', $data);
        $data = model('MatchCate')->where('id', 'IN', $data)->order('sort asc')->select();
        $this->responseSuccess($data);
    }
}